/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.gui.rendering;

import net.groupme.model.Resource;
import net.groupme.model.ResourceVisualization;

/**
 * created on 08.07.2007
 * 
 * This {@link Renderer} implementation renders shockwave/flash videos.
 * 
 * @author Mischa Frank, <a href="mailto:mail@planetfrank.net">mail@planetfrank.net</a>
 * @author last edited by: $Author: mischa $
 * 
 * @version $Revision: 1.3 $ $Date: 2008-02-28 12:40:13 $
 */
public class ShockwaveRenderer extends AbstractRenderer {

	/* (non-Javadoc)
	 * @see net.groupme.gui.rendering.AbstractRenderer#renderAsHTML(net.groupme.model.ResourceVisualization, java.lang.Integer, java.lang.Integer)
	 */
	@Override
	public String renderAsHTML(ResourceVisualization resourceVisualization,
			Integer groupWidth, Integer groupHeight, Integer zAxis) {
		String html = "";
		Resource resource = resourceVisualization.getResource();
		String width = "width:100px;";
		String height = "height:100px;";
		String widthMove = "width:100px;";
		if(resourceVisualization.getWidth() > 0){
			width = " width:" + (((resourceVisualization.getWidth()*groupWidth)/1000)-4) + "px;";
			widthMove = " width:" + (((resourceVisualization.getWidth()*groupWidth)/1000)) + "px;";
		}
		if(resourceVisualization.getHeight() > 0){
			height = " height:" + (((resourceVisualization.getHeight()*groupHeight)/1000)-55) + "px;";
		}
		
		String srcURL = resource.getURL().toString();
		//div initialisierung
		html += this.getDivAttributes(resourceVisualization, groupWidth, groupHeight, zAxis);
		//menu:
		html += this.getMenu(resourceVisualization, resourceVisualization.getURI().toString(), groupWidth);
		
		//video
		html += "<strong>" + resource.getName() + "</strong>" + "<br/>";
		html += "<object>";
		html += 	"<param name=\"movie\" value=\"" + srcURL  + "\"></param>";
		html += 	"<param name=\"wmode\" value=\"transparent\"></param>";
		html += 	"<embed id=\"" + resourceVisualization.getURI().toString() + "_contentVideo\" src=\"" + srcURL
						+ "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" style=\""+ width + height + " min-width:150px;\">";
		html += 	"</embed>";
		html += "</object>";
		
		// div open _tags
		html += "<div id=\"" + resourceVisualization.getURI().toString() + "_tags\" class=\"tag\" style=\"display:none;\">";
		// close div _tags
		html += "</div>";
		//close div URI
		html += "</div>";
		html += this.getMoveBar(resourceVisualization, widthMove);
		//close div _border
		html += "</div>";
		return html;
	}
}
